#ifndef __STDMYSTRING_H_
#define __STDMYSTRING_H_

#include <iostream>

class MyStringList; // 前置声明（如果在上面一个类里面写了下面一个类里面的东西，需要前置声明）
// 字符串
class StdMyString
{
public:
    StdMyString();
    StdMyString(const char *str);
    StdMyString(const StdMyString &str);
    ~StdMyString();

    StdMyString &operator=(const StdMyString &str);
    
    StdMyString &operator+=(const StdMyString &str);
    StdMyString &operator+=(const char &c);
    StdMyString operator+(const StdMyString &str);
    
    StdMyString &operator-=(const StdMyString &str);
    StdMyString operator-(const StdMyString &str);

    char &operator[](int index);

    // 逻辑运算符重载
    bool operator == (const StdMyString &str);
    bool operator > (const StdMyString &str);
    bool operator < (const StdMyString &str);
    // bool operator&&(const StdMyString &str); 

    friend std::ostream &operator<<(std::ostream &os, const StdMyString &str);
    friend std::istream &operator>>(std::istream &is, StdMyString &str);

    operator int();
    operator double();

    // 字符串切割函数
    MyStringList split(const StdMyString &str);


private:
    char *string;
    int size;
    int capacity;

};

// 输出运算符重载
std::ostream &operator<<(std::ostream &os, const StdMyString &str);
// 输入运算符重载
std::istream &operator>>(std::istream &is, StdMyString &str);


// 字符串数组
class MyStringList
{
public:
    MyStringList(int capacity = 15);
    ~MyStringList();
    // 拷贝构造 赋值运算符重载
    // - -= == > < [] >>

    MyStringList &operator+=(const StdMyString &str);

    MyStringList &operator<<(const StdMyString &str);

    MyStringList operator+(const MyStringList &list);

    friend std::ostream &operator<<(std::ostream &os, const MyStringList &list);

private:
    StdMyString *array;
    int size;
    int capacity;
};

std::ostream &operator<<(std::ostream &os, const MyStringList &list);

#endif